package com.quanyan.club.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.quanyan.club.service.SendTelMsgService;
import com.quanyan.sms.service.SmsService;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import sms.SmsApi;
import sms.model.Result;

/**
 * @Author Hugo.Wwg
 * @Since 2016-07-23
 */
@Service
public class SendTelMsgServiceImpl implements SendTelMsgService {

    private static final Logger logger = LoggerFactory.getLogger(SendTelMsgServiceImpl.class);

    @Autowired
    private SmsService smsService;

    public Result sendSMS(String tel) {
        Result rs = smsService.sendValidCodetToPhone(
                tel, SmsApi.MESSAGE_TEMPLATE_USER_REFUND, 60, 120);
        return rs;
    }

    public Result sendSMSContent(String mobile, String[] args)
    {
        logger.warn("发送短信入参：" + JSONObject.toJSONString(args));
        Result rs = smsService.sendMessageToPhone(
                mobile, SmsApi.MESSAGE_TEMPLATE_PLACE_ACTIVITY_NOTICE2,args,true);
        return rs;
    }

    public boolean verifyValidCode(String tel, String code) {
        boolean rs = smsService.verifyValidCode(tel, SmsApi.MESSAGE_TEMPLATE_USER_REFUND, code);
        return rs;
    }
}
